package com.fand.common.util;

import lombok.Builder;
import lombok.Data;

/**
 * Author: zhangjiabin
 * Email: javaboyok@163.com
 * CreateDate: 2021/5/24
 * Version: 1.0
 */
@Data
@Builder
public class ResultHelp<T> {

    private String msg;
    private int code = 0;
    private T data;

    public ResultHelp(String msg, int code, T data) {
        this.msg = msg;
        this.code = code;
        this.data = data;
    }

    public static ResultHelp success(){
        return ResultHelp.builder().build();
    }

    public static ResultHelp success(String msg){
        return ResultHelp.builder().msg(msg).build();
    }

    public static <T> ResultHelp success(T data){
        return ResultHelp.builder().data(data).build();
    }

    public static ResultHelp error(String msg,int code){
        return ResultHelp.builder().code(code).msg(msg).build();
    }

    public static ResultHelp errorMessage(String msg){
        return ResultHelp.builder().code(500).msg(msg).build();
    }
}
